<?php
/**
 * Контроллер обработчика ошибок приложения
 * 
 * @category Phorm
 * @package Controller_Module_Default
 * @name /Phorm/Controller/Default/Error.php
 * @copyright phorm.ru
 * @since 30.11.2010
 * @author vladimir@kachalov.net
 */

class Phorm_Controller_Module_Default_Error extends Phorm_Controller_Controller {

    /**
    * Обработка ошибок приложения
    * 
    * @return null
    */
    
	public function errorAction() {
    	
        $errors = $this->_getParam('error_handler');
        
        switch ($errors->type) {
        	
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
				
				if ($this->getInvokeArg('displayExceptions') == true) {
                	Zend_Controller_Action_HelperBroker::removeHelper("viewRenderer");
                	Zend_Debug::dump("ERROR: ".$errors->exception->getMessage().PHP_EOL.$errors->exception->getTraceAsString());
                }
                
                break;
                
            default:
            	
                /**
			    * Ошибка приложения (505)
			    */
                
                if ($this->getInvokeArg('displayExceptions') == true) {
                	Zend_Controller_Action_HelperBroker::removeHelper("viewRenderer");
                	Zend_Debug::dump("ERROR: ".$errors->exception->getMessage().PHP_EOL.$errors->exception->getTraceAsString());
                }
                
                break;
        }

    }
    
    
    /**
	* Страница не найдена
	* 
	* @return null
	*/
		
	public function notfoundAction() {
			
		//$this->getResponse()->setHttpResponseCode(404);
		$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
			
	}
		
		
	/**
	* Доступ запрещен
	* 
	* @return null
	*/
		
	public function forbiddenAction() {
			
		$this->_usersession->Refferer = $this->_request->getRequestUri();
		
		//$this->getResponse()->setHttpResponseCode(403);
		$this->getResponse()->setRawHeader('HTTP/1.1 403 Forbidden');
			
	}
		
}

 